package model.observer;

import jgf.Attribute;
import jgf.beans.ArcBean;
import jgf.beans.GraphBean;
import jgf.beans.NodeBean;

/**
 * 
 * @author Marcos Garcia Ortega <a href="mailto:thiamath@gmail.com">&lt;thiamath@gmail.com&gt;
 */
public interface JGSObserver {

	/**
	 * Gets the ID of the observer.
	 * @return An Integer with the ID of the observer.
	 */
	public Integer getId();

	/**
	 * Sets the ID of the observer
	 * @param id The new ID for the observer.
	 */
	public void setId(Integer id);

	//////////////////////
	// Graph management //
	//////////////////////

	// <editor-fold defaultstate="collapsed" desc="Graph management">
	/**
	 * Loads a graph into the observer.
	 * @param graph
	 */
	abstract void loadGraph(GraphBean graph);

	/**
	 * Sets the name of the graph.
	 * @param name A String with the new name of the graph.
	 */
	abstract void setName(String name);
	// </editor-fold>

	/////////////////////
	// Node management //
	/////////////////////
	
	// <editor-fold defaultstate="collapsed" desc="Node management">
	/**
	 * Catch the insertion of a node into the model.
	 * @param node All the needed information to recreate the new node
	 *		in the view.
	 */
	abstract public void insertNode(NodeBean node);

	/**
	 * Catch the deletion of a node into the model.
	 * @param node All the needed information to delete the node in the view.
	 */
	abstract public void deleteNode(NodeBean node);

	/**
	 * Catch the update of a node in the model.
	 * @param node All the new information for the updated node.
	 */
	abstract public void updateNode(NodeBean node);

	/**
	 * Sets a source in the view.
	 * @param node All the needed information to set the node as source.
	 */
	abstract public void setSource(NodeBean node);

	/**
	 * Unsets a source in the view.
	 * @param node All the neede information to unset the node from the sources
	 *		list.
	 */
	abstract public void unsetSource(NodeBean node);

	/**
	 * Sets a sink in the view.
	 * @param node All the needed information to set the node as source.
	 */
	abstract public void setSink(NodeBean node);

	/**
	 * Unsets a sink in the view.
	 * @param node All the neede information to unset the node from the sinks
	 *		list.
	 */
	abstract public void unsetSink(NodeBean node);
	// </editor-fold>

	////////////////////
	// Arc management //
	////////////////////

	// <editor-fold defaultstate="collapsed" desc="Arc management">
	/**
	 * Catch the insertion of an arc in the model.
	 * @param arc All the needed information to recreate the arc into the view.
	 */
	abstract public void insertArc(ArcBean arc);

	/**
	 * Catch the deletion of an arc in the model.
	 * @param arc All the needed information to delete the arc in the view.
	 */
	abstract public void deleteArc(ArcBean arc);

	/**
	 * Updates the arc in the view as was updated in the model.
	 * @param arc The new information for the arc.
	 */
	abstract public void updateArc(ArcBean arc);
	// </editor-fold>

	//////////////////////////
	// Attribute Management //
	//////////////////////////

	// <editor-fold defaultstate="collapsed" desc="Attribute Management">
	/**
	 * Adds a new default attribute for nodes to the view to allow a secure
	 * edition of the graphs.
	 * @param attribute The new attribute.
	 */
	abstract public void addDefaultNodeAttribute(Attribute attribute);

	/**
	 * Removes the attribute from the list of default attributes for nodes.
	 * @param attribute The attribute to remove.
	 */
	abstract public void removeDefaultNodeAttribute(Attribute attribute);

	/**
	 * Updates an attribute of the list of default attributes for nodes.
	 * @param previousName The previous name of the attribute.
	 * @param newValue The new attribute that will substitute the previous one.
	 */
	abstract public void updateDefaultNodeAttribute(String previousName, Attribute newValue);

	/**
	 * Adds a new default attribute for arcs to the view to allow a secure
	 * edition of the graphs.
	 * @param attribute The new attribute.
	 */
	abstract public void addDefaultArcAttribute(Attribute attribute);

	/**
	 * Removes the attribute from the list of default attributes for arcs.
	 * @param attribute The attribute to remove.
	 */
	abstract public void removeDefaultArcAttribute(Attribute attribute);

	/**
	 * Updates an attribute of the list of default attributes for arcs.
	 * @param previousName The previous name of the attribute.
	 * @param newValue The new attribute that will substitute the previous one.
	 */
	abstract public void updateDefaultArcAttribute(String previousName, Attribute newValue);
	// </editor-fold>

}
